package com.lyf.viewapp.util;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lyf.viewapp.R;

import java.util.List;

/**
 * Created by lyf on 2018/4/18 12:48
 *
 * @author lyf
 * desc：跳转界面适配
 */
public class EnterAdapter extends BaseAdapter {

    private List<EnterBean> mEnterBeans;
    private LayoutInflater mInflater;

    public EnterAdapter(Context context,
                        List<EnterBean> mEnterBeans) {
        // this.context = context;
        this.mEnterBeans = mEnterBeans;
        mInflater = LayoutInflater.from(context);

    }

    @Override
    public int getCount() {
        return mEnterBeans.size();
    }

    @Override
    public Object getItem(int position) {
        return mEnterBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.main_item, null);
            holder.name = convertView.findViewById(R.id.main_item_name);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.name.setText(mEnterBeans.get(position).getName());
        return convertView;
    }

    private class ViewHolder{
        TextView name;
    }
}
